package com.lt.crm.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lt.crm.pojo.CstService;
import com.lt.crm.pojo.Product;
import com.lt.crm.service.CstServiceService;
import javax.annotation.Resource;

import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

;

@Controller
@RequestMapping("/plan")
public class PlanController {

    @Resource
    CstServiceService cstServiceService;

    @RequestMapping("/list")
    public String list(Model model,
                       @RequestParam(required = false, defaultValue = "1") Integer pageIndex,
                       @RequestParam(required = false, defaultValue = "") String svrCustName,
                       @RequestParam(required = false, defaultValue = "") String svrDueTo,
                       @RequestParam(required = false, defaultValue = "") String svrTitle) {
        Page<Product> page = new  Page<>(pageIndex,5);
        Page<CstService> svrPage = cstServiceService.findAllByPage(svrCustName, svrDueTo, svrTitle, page);
        model.addAttribute("planPage", svrPage);
        model.addAttribute("svrCustName", svrCustName);
        model.addAttribute("svrDueTo", svrDueTo);
        model.addAttribute("svrTitle", svrTitle);
        return "plan/list";
    }

    @RequestMapping("/add")
    public String add(Model model) {
        //model.addAttribute("users",sysUserService.list());
        return "plan/add";
    }


}
